<?php
require_once '../model/db.php';

$name = $_POST["name"];
$password = $_POST["password"];

$data = "";
$status = -1;
$db = new MySQLDB;
if ($db->connect_db() == false) {
    return;
}

//校验用户是否存在
if ($db->check_user($name)) {
    if ($db->check_password($name, $password)) {
        //登陆成功,跳转到聊天界面
        $data = "http://127.0.0.1/view/login_user.php";
        $status = 0;
    }else{
        $status = 2;
        $data = "密码错误!";
    }
} else {
    $status = 1;
    $data = "用户不存在";
}

$db->close_db();
$arr = array('status' => $status, 'data' => $data);
echo json_encode($arr);
?>